<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="common/header.jsp" %>
<div class="clearfix"></div>
<div class="row">

    <div class="col-md-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>
                    APP 审核列表 <i class="fa fa-user"></i>
                    <small>${userSession.userName}
                        - 您可以通过搜索或者其他的筛选项对APP的信息进行审核操作。^_^
                    </small>
                </h2>
                <div class="clearfix"></div>
            </div>
            <div class="x_content" >
                <form method="post" action="/app/queryAll" id="turning">

                    <%--<input type="hidden" name="pageIndex" value="1" />--%>
                    <input type="hidden" name="pageNumber" id="pageNumber">
                        <input type="hidden" name="status" value="1"/>
                    <ul>
                        <li>
                            <div class="form-group" >
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">软件名称</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input name="softwareName" type="text" class="form-control col-md-7 col-xs-12"
                                           value="${softwareName}">
                                </div>
                            </div>
                        </li>

                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">所属平台</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select name="flatformId" class="form-control" id="flatId">

                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">一级分类</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select id="categoryLevel1" name="queryCategoryLevel1" class="form-control" onchange="er(1)">

                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">二级分类</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input type="hidden" name="categorylevel2list" id="categorylevel2list"/>
                                    <select name="categoryLevel2" id="queryCategoryLevel2" class="form-control" onchange="er(19)">

                                        <option value="">----</option>

                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">三级分类</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select name="categoryLevel3" id="queryCategoryLevel3" class="form-control">

                                        <option value="">----</option>

                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <button type="submit" class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询</button>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
    </div>
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_content">
                <p class="text-muted font-13 m-b-30"></p>
                <div id="datatable-responsive_wrapper"
                     class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                    <div class="row">
                        <div class="col-sm-12">
                            <table id="datatable-responsive"
                                   class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                   cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info"
                                   style="width: 100%;">
                                <thead>
                                <tr role="row">
                                    <th class="sorting_asc" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 70px;" aria-label="First name: activate to sort column descending"
                                        aria-sort="ascending">软件名称
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 10px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        APK名称
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 90px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        软件大小(单位:M)
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 50px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        所属平台
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 170px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        所属分类(一级分类、二级分类、三级分类)
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 30px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        状态
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 30px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        下载次数
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 64px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        最新版本号
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 30px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        操作
                                    </th>
                                </tr>
                                </thead>
                                <tbody>

                                <c:forEach var="appInfo" items="${sessionScope.pageDto.pageData}" varStatus="status">
                                    <tr ${vs.index%2==0?"bgcolor='lightgrey'":'#93A2B2'} role="row" class="odd">
                                        <td tabindex="0" class="#82ad2b">${appInfo.softwareName}</td>
                                        <td>${appInfo.APKName }</td>
                                        <td>${appInfo.softwareSize }</td>
                                        <td>${appInfo.flatformName }</td>
                                        <td>${appInfo.categoryLevel1Name } -> ${appInfo.categoryLevel2Name }
                                            -> ${appInfo.categoryLevel3Name }</td>
                                        <td>${appInfo.statusName }</td>
                                        <td>${appInfo.downloads }</td>
                                        <td id="avn">${appInfo.versionNo}</td>
                                        <td>
                                                <%--<button type="button"&lt;%&ndash; class="btn btn-default checkApp"--%>
                                                <%--appinfoid="${appInfo.id }" versionid="${appInfo.versionId }" status="${appInfo.status }"--%>
                                                <%--statusname="${appInfo.statusName }"--%>
                                                <%--data-toggle="tooltip" data-placement="top" data-original-title="查看并审核APP">--%>
                                                <%--<a href="${pageContext.request.contextPath }/app/check/${appInfo.id}/${appInfo.versionId}">审核</a></button>--%>

                                                      <button onclick="shen(${appInfo.id },${appInfo.versionId })">审核</button>
                                            <%--<a href="${pageContext.request.contextPath }/app/check/${appInfo.id}/${appInfo.versionId}">审核</a>--%>

                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-5">
                            <div class="dataTables_info" id="datatable-responsive_info"
                                 role="status" aria-live="polite">共${pageDto.totalCount}条记录,
                                第${pageDto.pageNumber}页
                            </div>
                        </div>
                        <div class="col-sm-7">
                            <div class="dataTables_paginate paging_simple_numbers"
                                 id="datatable-responsive_paginate">
                                <ul class="pagination">
                                    <c:if test="${pageDto.pageNumber > 1}">
                                        <li class="paginate_button previous"><a aria-controls="datatable-responsive"
                                                                                data-dt-idx="0"
                                                                                href="javascript:turn(1)"
                                                                                tabindex="0">首页</a>
                                        </li>
                                        <li class="paginate_button "><a
                                                href="javascript:turn(${pageDto.pageNumber-1<1?1:pageDto.pageNumber-1})"
                                                aria-controls="datatable-responsive" data-dt-idx="1"
                                                tabindex="0">上一页</a>
                                        </li>
                                    </c:if>
                                    <c:if test="${pageDto.pageNumber < pageDto.totalPages }">
                                        <li class="paginate_button ">
                                            <a
                                                    href="javascript:turn(${pageDto.pageNumber+1>pageDto.totalPages?pageDto.totalPages:pageDto.pageNumber+1})"
                                                    aria-controls="datatable-responsive" data-dt-idx="1"
                                                    tabindex="0">下一页</a>
                                        </li>
                                        <li class="paginate_button next"><a
                                                href="javascript:turn(${pageDto.totalPages })"
                                                aria-controls="datatable-responsive" data-dt-idx="7"
                                                tabindex="0">最后一页</a>
                                        </li>
                                    </c:if>
                                </ul>

                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    function turn(pageNumber) {
        document.getElementById("pageNumber").value = pageNumber;
        document.getElementById("turning").submit();
    }
    $(function(){
       //一级
        $.ajax({
            type: "post",
            dateType: "json",
            url: "${pageContext.request.contextPath}/app/queryLv1",
            success: function (responseData) {
                $("#categoryLevel1").append("<option value=''>--请选择--</option>");
                $.each($.parseJSON(responseData), function (index, obj) {
                    $("#categoryLevel1").append("<option value='" + obj.id + "'>" + obj.categoryName + "</option>");
                });
            },
            error:function(data){//当访问时候，404，500 等非200的错误状态码
                console.info(data);
                alert("加载二级分类失败！");}
        });
//平台
        $("#flatId").empty();
        $.ajax({
            type: "post",
            dateType: "json",
            url:"${pageContext.request.contextPath}/app/queryflat",
            success: function (responseData) {
                $("#flatId").append("<option value=''>--请选择--</option>");
                $.each($.parseJSON(responseData), function (index, obj) {
                    $("#flatId").append("<option value='" + obj.valueId + "'>" + obj.valueName + "</option>");
                });
            }
        });
    })

//二级
    function er(id) {
        $("#categoryLevel2").empty();
        $.ajax({
            type:"post",
            dateType:"json",
            data:{"id":id},
            url: "${pageContext.request.contextPath}/app/queryLv2",
            success: function (responseData) {
                $("#categoryLevel2").append("<option value=\"\">--请选择--</option>");
                $.each($.parseJSON(responseData), function (index, obj) {
                    $("#categoryLevel2").append("<option value='" + obj.id + "'>" + obj.categoryName + "</option>");
                });
            }
        });
    }
    //审核
        function shen(id,versionId) {
            if(versionId!=null){
//                alert(id+"*********"+versionId+"......");
                location.href="${pageContext.request.contextPath }/app/check/"+id+"/"+versionId;
            }else{
//                alert(id+"===="+versionId);
                alert("该App没有上传最新版本，不能进行此操作。");
                location.href="${pageContext.request.contextPath }/app/queryAll?status=1";
            }
        }

</script>

<%@include file="common/footer.jsp" %>
<%--<script src="${pageContext.request.contextPath }/statics/localjs/rollpage.js"></script>--%>
<%--<script src="${pageContext.request.contextPath }/statics/localjs/applist.js"></script>--%>